﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using System.Security.Principal;
using Microsoft.ReportingServices;
using System.Net;
using System.Configuration;

namespace Prisa.UI.Reportes
{
    public partial class frmCapitalInvertido : Form 
    {
        public frmCapitalInvertido()
        {
            InitializeComponent();
        }

        private void frmCapitalInvertido_Load(object sender, EventArgs e)
        {
            reportViewer1.ShowPageNavigationControls = false;
            reportViewer1.ShowCredentialPrompts = false;

            var user = ConfigurationManager.AppSettings.Get("userReport");
            var pws = ConfigurationManager.AppSettings.Get("pwsReport");
            reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = new NetworkCredential(user, pws);

            var ipServer = ConfigurationManager.AppSettings.Get("ipServer");
            var path = ConfigurationManager.AppSettings.Get("pathCapInvertido");
            reportViewer1.ProcessingMode = ProcessingMode.Remote;
            reportViewer1.ServerReport.ReportPath = path;
            reportViewer1.ServerReport.ReportServerUrl = new Uri(ipServer, System.UriKind.Absolute);


            this.reportViewer1.RefreshReport();

        }

        private void reportViewer1_ReportError(object sender, ReportErrorEventArgs e)
        {
            //MessageBox.Show("No se puede obtener el informe", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void reportViewer1_Load(object sender, EventArgs e)
        {
            if (reportViewer1.LocalReport.DataSources != null)
            {
                //MessageBox.Show("No se puede obtener el informe", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //reportViewer1.LocalReport.DataSources *= null;

                //frmCapitalInvertido frm = new frmCapitalInvertido();
                //frm.Close();
            }
        }
    }
}
